home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wrcmdd / vrsh.frm < prev    next >
Text File  |  1995-02-28  |  4KB  |  144 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Remote Shell"
  5.    ClientHeight    =   5820
  6.    ClientLeft      =   180
  7.    ClientTop       =   690
  8.    ClientWidth     =   9390
  9.    FontBold        =   0   'False
  10.    FontItalic      =   0   'False
  11.    FontName        =   "Terminal"
  12.    FontSize        =   9
  13.    FontStrikethru  =   0   'False
  14.    FontUnderline   =   0   'False
  15.    Height          =   6225
  16.    Left            =   120
  17.    LinkTopic       =   "Form1"
  18.    ScaleHeight     =   5820
  19.    ScaleWidth      =   9390
  20.    Top             =   345
  21.    Width           =   9510
  22.    Begin CommandButton ExitOut 
  23.       Caption         =   "Exit"
  24.       Height          =   375
  25.       Left            =   5040
  26.       TabIndex        =   7
  27.       Top             =   720
  28.       Width           =   1695
  29.    End
  30.    Begin TextBox User 
  31.       Height          =   285
  32.       Left            =   3360
  33.       TabIndex        =   1
  34.       Top             =   240
  35.       Width           =   1335
  36.    End
  37.    Begin TextBox Host 
  38.       Height          =   285
  39.       Left            =   960
  40.       TabIndex        =   0
  41.       Top             =   240
  42.       Width           =   1455
  43.    End
  44.    Begin TextBox Cmd 
  45.       Height          =   285
  46.       Left            =   1800
  47.       TabIndex        =   3
  48.       Top             =   600
  49.       Width           =   2895
  50.    End
  51.    Begin CommandButton Execute 
  52.       Caption         =   "Execute"
  53.       Height          =   375
  54.       Left            =   5040
  55.       TabIndex        =   4
  56.       Top             =   240
  57.       Width           =   1695
  58.    End
  59.    Begin Label Label3 
  60.       BackColor       =   &H00C0C0C0&
  61.       Caption         =   "User:"
  62.       Height          =   255
  63.       Left            =   2640
  64.       TabIndex        =   6
  65.       Top             =   240
  66.       Width           =   615
  67.    End
  68.    Begin Label Label2 
  69.       BackColor       =   &H00C0C0C0&
  70.       Caption         =   "Host:"
  71.       Height          =   255
  72.       Left            =   240
  73.       TabIndex        =   5
  74.       Top             =   240
  75.       Width           =   615
  76.    End
  77.    Begin Label Label1 
  78.       BackColor       =   &H00C0C0C0&
  79.       Caption         =   "Enter Command:"
  80.       Height          =   255
  81.       Left            =   240
  82.       TabIndex        =   2
  83.       Top             =   600
  84.       Width           =   1455
  85.    End
  86. End
  87. Declare Function WinsockRCmd Lib "RCMD.DLL" (ByVal RHost As String, ByVal RPort As Integer, ByVal LocalUser As String, ByVal RemoteUser As String, ByVal Cmd As String, ByVal ErrorMsg As String, ByVal ErrLen As Integer) As Integer
  88. Declare Function RCmdRead Lib "RCMD.DLL" (ByVal hRCmd As Integer, ByVal RData As String, ByVal RCount As Integer) As Integer
  89. Declare Function RCmdClose Lib "RCMD.DLL" (ByVal hRCmd As Integer) As Integer
  90. Declare Function RCmdHandle Lib "RCMD.DLL" (ByVal hRCmd As Integer) As Integer
  91.  
  92. Sub Execute_Click ()
  93.  
  94.     If Len(Host.Text) = 0 Or Len(Cmd.Text) = 0 Then
  95.       Beep
  96.       Host.SetFocus
  97.       Exit Sub
  98.     End If
  99.  
  100.     RCmdErrorMsg$ = Space$(128)
  101.     RCmdErrorLen% = 128
  102.     RetryCount% = 0
  103.  
  104.     ' Execute the command.  We will retry on the Winsock errors -10058 and -10061.
  105.     ' These are the Shutdown and Connection Refused errors that some TCP/IP
  106.     ' packages return occasionally.  A retry will usually give success.
  107.     Do
  108.        hRCmd% = WinsockRCmd(Host.Text, 514, User.Text, User.Text, Cmd.Text, RCmdErrorMsg$, RCmdErrorLen%)
  109.        RetryCount% = RetryCount% + 1
  110.     Loop While (hRCmd% = -10058 Or hRCmd% = -10061) And RetryCount% < 10
  111.  
  112.     Cls
  113.     ScaleMode = 4
  114.     CurrentY = 5
  115.  
  116.     If hRCmd% < 0 Then
  117.       Beep
  118.       e$ = "Command Was Unsuccessful" & Chr$(10) & Trim$(RCmdErrorMsg$)
  119.       MsgBox e$
  120.       Host.SetFocus
  121.       Exit Sub
  122.     End If
  123.  
  124.     Do
  125.        c$ = Chr$(0)
  126.        result% = RCmdRead(hRCmd%, c$, 1)
  127.        If result% > 0 Then
  128.          Print c$;
  129.        End If
  130.     Loop While result% > 0
  131.  
  132.     result% = RCmdClose(hRCmd%)
  133.  
  134.     MsgBox "Command Was Successful"
  135.  
  136. End Sub
  137.  
  138. Sub ExitOut_Click ()
  139.  
  140.     End
  141.  
  142. End Sub
  143.  
  144.